<template>
  <div class="home">
    <el-row>
      <el-col :span="12">
        <div class="logo">
          <div><img src="../assets/logo.png" alt="" /></div>
          <div>后台管理系统</div>
        </div>
        <el-menu
          default-active="1-4-1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          :collapse="isCollapse"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-menu-item index="1">
            <i class="el-icon-menu"></i>
            <span slot="title">主页</span>
          </el-menu-item>

          <el-menu-item index="2">
            <i class="el-icon-document"></i>
            <router-link to="/about" tag="span">单独的路由</router-link>
          </el-menu-item>

          <el-menu-item index="3">
            <i class="el-icon-right"></i>
            <span slot="title">外链</span>
          </el-menu-item>

          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-document"></i>
              <span>二级菜单</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <i class="el-icon-s-grid"></i>
                <router-link to="/forms" tag="span">表格</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <i class="el-icon-right"></i>
                <span>外链</span>
              </el-menu-item>
              <el-submenu index="1-3">
                <template slot="title">
                  <i class="el-icon-document"></i>
                  <span>三级菜单</span>
                </template>
                <el-menu-item index="1-3-1">
                  <i class="el-icon-bell"></i>
                  <router-link to="ck" tag="span">查看消息</router-link>
                </el-menu-item>
                <el-menu-item index="1-3-2">
                  <i class="el-icon-setting"></i>
                  <router-link to="/xg" tag="span">修改密码</router-link>
                </el-menu-item>
                <el-menu-item index="1-3-3">
                  <i class="el-icon-user-solid"></i>
                  <router-link to="/jb" tag="span">基本资料</router-link>
                </el-menu-item>
                <el-menu-item index="1-3-4">
                  <i class="el-icon-right"></i>
                  <span>外链</span>
                </el-menu-item>
              </el-submenu>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
    <div style="width: 100%">
      <div class="heng">
        <div>
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
            <el-radio-button :label="isCollapse">
              <div @click="fn_huan">
                <i class="el-icon-s-grid"></i>
              </div>
            </el-radio-button>
          </el-radio-group>
        </div>
        <div>
          <el-dropdown>
            <span class="el-dropdown-link">
              小明<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <router-link to="/xg" tag="span">修改密码</router-link>
              </el-dropdown-item>
              <el-dropdown-item>
                <router-link to="/jb" tag="span">基本信息</router-link>
              </el-dropdown-item>
              <el-dropdown-item>
                <div @click="deletefn">退出登录</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
      <div class="wid">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      isCollapse: false,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    async deletefn() {
      await localStorage.removeItem("token"); // 删除本地存储
      this.$router.push({ name: "Login" });
    },
    async fn_huan() {
      this.isCollapse = !this.isCollapse
    
      console.log(this.isCollapse);
    },
  },
};
</script>
<style>
.home {
  display: flex;
}
.logo {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 200px;
}
.logo img {
  padding: 0 10px 0;
  width: 40px;
  height: 40px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.heng {
  display: flex;
  width: 80%;
  height: 40px;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
}
.wid {
  width: 100%;
  height: 100%;
}
</style>